import request from '@/utils/request'

const prePath = '/purch'

// =================  重构 api start ============== //
//校验能否采购
export function applicationsValidatePurch(data) {
  return request({
    url: prePath + '/applications/validatePurch',
    method: 'post',
    data,
  })
}
//校验能否采购
export function applicationsSummaryValidatePurch(data) {
  return request({
    url: prePath + '/applicationSummary/validatePurch',
    method: 'post',
    data,
  })
}
//获取申购订单
export function postPurchApplicationPage(data) {
  return request({
    url: prePath + '/applications/customizeList/page',
    method: 'post',
    data,
  })
}
export function getPurchApplicationPage(params) {
  return request({
    url: prePath + '/applications/page',
    method: 'get',
    params,
  })
}
export function postPendPurchApplicationPage(data) {
  return request({
    url: prePath + '/applications/selectPendPurchList',
    method: 'post',
    data,
  })
}

//获取申购订单
export function getPurchApplicationAll(params) {
  return request({
    url: prePath + '/applications/all',
    method: 'get',
    params,
  })
}
//申购明细分页查询
export function purchApplicationDetailCustomizeListPage(data) {
  return request({
    url: prePath + '/applicationDetails/customizeList/page',
    method: 'post',
    data,
  })
}
//申购明细自定义查询
export function purchApplicationDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/applicationDetails/customizeList/all',
    method: 'post',
    data,
  })
}

//申购明细分组查询
export function purchApplicationDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/applicationDetails/customizeGroups',
    method: 'post',
    data,
  })
}
//采购获取一条打印数据
export function getPurchOrderPrint(data) {
  return request({
    url: prePath + '/orders/print',
    method: 'post',
    data,
  })
}
//采购单明细分页查询
export function purchOrdersDetailCustomizeListPage(data) {
  return request({
    url: prePath + '/orders/customizeList/page',
    method: 'post',
    data,
  })
}
//采购单明细自定义查询
export function purchOrdersDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/orderDetails/customizeList/all',
    method: 'post',
    data,
  })
}
//采购单明细分组查询
export function purchOrdersDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/orders/customizeGroups',
    method: 'post',
    data,
  })
}

//采购单明细页分页查询
export function fatchPurchOrdersDetailListCustomizeListPage(data) {
  return request({
    url: prePath + '/orderDetails/customizeList/page',
    method: 'post',
    data,
  })
}
//采购单明细页自定义查询
export function fatchPurchOrdersDetailListCustomizeListAll(data) {
  return request({
    url: prePath + '/orderDetails/customizeList/all',
    method: 'post',
    data,
  })
}
//采购单明细页分组查询
export function fatchPurchOrdersDetailListCustomizeGroups(data) {
  return request({
    url: prePath + '/orderDetails/customizeGroups',
    method: 'post',
    data,
  })
}

/**
 * @param ids {[]}
 * @param method {string} merge 合并申购单 ratify 批准申购单 revoke 撤销 split 拆分申购单 stop 终止 submit 提交
 */
export function methodPurchApplication(data, method) {
  return request({
    url: prePath + '/applications/' + method,
    method: 'post',
    data,
  })
}

/**
 * @param ids {[]}
 * @param method {string} break 终止采购单 execute 执行 revoke 撤销 submit 提交
 */
export function methodPurchOrder(data, method) {
  return request({
    url: prePath + '/orders/' + method,
    method: 'post',
    data,
  })
}
// 带量产品上限采购时校验
export function bandQuantityHighValidateDoPurch(data) {
  return request({
    url: prePath + '/orders/bandQuantityHighValidateDoPurch',
    method: 'post',
    data,
  })
}
// 带量产品上限提交校验
export function bandQuantityHighValidateSubmit(data) {
  return request({
    url: prePath + '/orders/bandQuantityHighValidateSubmit',
    method: 'post',
    data,
  })
}
/**
 *
 * 采购单总汇状态方法
 * @param ids {[]}
 * @param method {string}  execute 执行 ratify 批准 revoke 撤销 stop 终止 submit 提交
 *
 */
export function methodPurchOrderSummary(data, method) {
  return request({
    url: prePath + '/orderSummary/' + method,
    method: 'post',
    data,
  })
}

export function deletePurchOrderSummaryPage(data) {
  return request({
    url: prePath + '/orderSummary',
    method: 'delete',
    data,
  })
}

//获取采购汇总单
export function fatchPurchOrderSummaryCustomizeListPage(data) {
  return request({
    url: prePath + '/orderSummary/customizeList/page',
    method: 'post',
    data,
  })
}
//采购获取一条打印数据
export function getPurchOrderSummaryPrint(data) {
  return request({
    url: prePath + '/orderSummary/print',
    method: 'post',
    data,
  })
}
export function fatchPurchOrderSummaryCustomizeGroups(data) {
  return request({
    url: prePath + '/orderSummary/customizeGroups',
    method: 'post',
    data,
  })
}
export function fatchPurchOrderSummaryCustomizeListAll(data) {
  return request({
    url: prePath + '/orderSummary/customizeList/all',
    method: 'post',
    data,
  })
}
// 采购汇总单新增合并采购单生成汇总单
export function postPurchOrderSummaryMergeInsert(data) {
  return request({
    url: prePath + '/orderSummary/mergeInsert',
    method: 'post',
    data,
  })
}
// 采购汇总单新增合并采购单生成汇总单  保存并提交
export function postPurchOrderSummarySaveAndSubmit(data) {
  return request({
    url: prePath + '/orderSummary/saveAndSubmit',
    method: 'post',
    data,
  })
}

// 采购汇总单整单驳回
export function postPurchOrderSummaryReject(data) {
  return request({
    url: prePath + '/orderSummary/reject',
    method: 'post',
    data,
  })
}

//采购汇总单 采购单驳回
export function postPurchOrderSummaryBatchReject(data) {
  return request({
    url: prePath + '/orderSummary/batchReject',
    method: 'post',
    data,
  })
}

//采购汇总单新增采购接口
export function purchOrderSummaryAddPurchOrder(data) {
  return request({
    url: prePath + '/orderSummary/addPurchOrder',
    method: 'post',
    data,
  })
}

//采购汇总单删除采购接口
export function purchOrderSummaryDeletePurchOrder(data) {
  return request({
    url: prePath + '/orderSummary/deletePurchOrder',
    method: 'post',
    data,
  })
}

//获取采购汇总单根据{id}获取一条数据
export function fatchPurchOrderSummaryId(id) {
  return request({
    url: prePath + `/orderSummary/${id}`,
    method: 'get',
  })
}

// 采购汇总打印
export function printPurchOrderSummary(id) {
  return request({
    url: prePath + `/orderSummary/${id}/print`,
    method: 'get',
  })
}

// 采购汇总导出
export function exportPurchOrderSummary(data) {
  return request({
    url: prePath + `/orderSummary/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
export function excelOrderList(data) {
  return request({
    url: prePath + `/adjustPriceOrderDetails/excelOrderList`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
// 采购汇总导出
export function exportPurchOrderDetailSummary(data) {
  return request({
    url: prePath + `/orderSummaryDetail/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

//采购总汇单明细分页查询
export function purchOrderSummaryDetailCustomizeListPage(data) {
  return request({
    url: prePath + '/orderSummaryDetail/customizeList/page',
    method: 'post',
    data,
  })
}

//采购总汇单明细自定义查询
export function purchOrderSummaryDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/orderSummaryDetail/customizeList/all',
    method: 'post',
    data,
  })
}
//采购总汇单明细分组查询
export function purchOrderSummaryDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/orderSummaryDetail/customizeGroups',
    method: 'post',
    data,
  })
}

// ================= 重构 api end ============== //

//获取申购订单
export function getPurchApplication(id) {
  return request({
    url: prePath + '/applications/' + id,
    method: 'get',
  })
}

//创建申购单
export function createPurchApplication(data) {
  return request({
    url: prePath + '/applications',
    method: 'post',
    data,
  })
}
export function createPurchApplicationAndSave(data) {
  return request({
    url: prePath + '/applications/saveAndSubmit',
    method: 'post',
    data,
  })
}

//删除申购单
export function removePurchApplication(data) {
  return request({
    url: prePath + '/applications',
    method: 'delete',
    data,
  })
}

//更新申购单
export function updatePurchApplication(data) {
  return request({
    url: prePath + '/applications/byPost',
    method: 'post',
    data,
  })
}

//打印申购单
export function printPurchApplication(id) {
  return request({
    url: prePath + `/applications/${id}/print`,
    method: 'get',
  })
}

//导出申购单
export function exportPurchApplication(data) {
  return request({
    url: prePath + `/applications/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

//导出申购单
export function exportPurchApplicationDetail(data) {
  return request({
    url: prePath + `/applicationDetails/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
//打印申购单
export function printPurchApplicationDetail(data) {
  return request({
    url: prePath + `/applicationDetails/printDetailList`,
    method: 'post',
    data,
  })
}
// 申购单查询产品
export function postPurchProductWithStock(data) {
  return request({
    url: prePath + '/applications/selectProductWithStock',
    method: 'post',
    data,
  })
}

export function applicationDetailAddProduct(data) {
  return request({
    url: prePath + '/applicationDetails/selectForPurchOrder',
    method: 'post',
    data,
  })
}

export function applicationSummaryDetailAddProduct(data) {
  return request({
    url: prePath + '/applicationSummaryDetail/selectForPurchOrder',
    method: 'post',
    data,
  })
}

export function exportApplicationSummary(data) {
  return request({
    url: prePath + `/applicationSummary/excel`,
    method: 'POST',
    data,
    responseType: 'blob',
  })
}

export function exportApplicationSummaryDetail(data) {
  return request({
    url: prePath + `/applicationSummaryDetail/excel`,
    method: 'POST',
    data,
    responseType: 'blob',
  })
}

//拆分申购单 ids
export function splitPurchApplication(data) {
  return request({
    url: prePath + '/applications/split',
    method: 'post',
    data,
  })
}

//提交申购单 传申购单id的数组 ids
export function submitPurchApplication(data) {
  return request({
    url: prePath + '/applications/submit',
    method: 'post',
    data,
  })
}

//撤回申购单 传申购单id的数组
export function retractPurchApplication(data) {
  return request({
    url: prePath + '/applications/retract',
    method: 'post',
    data,
  })
}

//批准申购单 传申购单id的数组
export function ratifyPurchApplication(data) {
  return request({
    url: prePath + '/applications/ratify',
    method: 'post',
    data,
  })
}
//终止申购单 传申购单id的数组
export function stopPurchApplication(data) {
  return request({
    url: prePath + '/applications/stop',
    method: 'post',
    data,
  })
}
//执行申购单 传申购单id的数组
export function executePurchApplication(data) {
  return request({
    url: prePath + '/applications/execute',
    method: 'post',
    data,
  })
}
//撤销申购单 传申购单id的数组
export function revokePurchApplication(data) {
  return request({
    url: prePath + '/applications/revoke',
    method: 'post',
    data,
  })
}
//驳回申购单
export function rejectPurchApplication(data) {
  return request({
    url: prePath + '/applications/reject',
    method: 'post',
    data,
  })
}
//申购获取一条打印数据
export function getPurchApplicationPrint(data) {
  return request({
    url: prePath + '/applications/print',
    method: 'post',
    data,
  })
}
//获取申购单明细
export function getPurchApplicationDetailAll(params) {
  return request({
    url: prePath + '/applicationDetails/all',
    method: 'get',
    params,
  })
}

// 申购单多单号查询产品列表
export function getMorePurchApplicationDetail(params) {
  return request({
    url: prePath + '/applicationDetails/simpleAll',
    method: 'get',
    params,
  })
}

//采购单生成发货单时明细
export function getPurchApplicationDetailAllPage(params) {
  return request({
    url: prePath + '/applicationDetails/page',
    method: 'get',
    params,
  })
}

export function getPurchApplicationOrderCustomizeList(data) {
  return request({
    url: prePath + '/applications/customizeList/page',
    method: 'post',
    data,
  })
}

//采购模板分页
export function getPurchTemplatePage(params) {
  return request({
    url: prePath + '/templates/page',
    method: 'get',
    params,
  })
}

//采购模板分页
export function getPurchTemplateCustomizeListPage(data) {
  return request({
    url: prePath + '/templates/customizeList/page',
    method: 'post',
    data,
  })
}

//获取采购模板所有明细
export function getPurchTemplateDetailAll(params) {
  return request({
    url: prePath + '/templateDetails/merge',
    method: 'get',
    params,
  })
}

export function getPurchTemplateDetailCustomizeList(data) {
  return request({
    url: prePath + '/templateDetails/customizeList/all',
    method: 'post',
    data,
  })
}

export function getDeptProduct(data) {
  return request({
    url: prePath + '/templates/product',
    method: 'post',
    data,
  })
}

export function getPurchTemplateExcel(data) {
  return request({
    url: prePath + '/templates/excel',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

export function getPurchTemplateDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/templateDetails/customizeGroups',
    method: 'post',
    data,
  })
}

export function getPurchTemplateDetailCustomizePage(data) {
  return request({
    url: prePath + '/templateDetails/customizeList/page',
    method: 'post',
    data,
  })
}

export function getPurchTemplateById(id) {
  return request({
    url: prePath + '/templates/' + id,
    method: 'get',
  })
}

//新增采购模板
export function createPurchTemplate(data) {
  return request({
    url: prePath + '/templates',
    method: 'post',
    data,
  })
}

//更新采购模板
export function updatePurchTemplate(data) {
  return request({
    url: prePath + '/templates/byPost',
    method: 'post',
    data,
  })
}

//删除采购模板
export function deletePurchTemplate(data) {
  return request({
    url: prePath + '/templates',
    method: 'delete',
    data,
  })
}

//获取采购单分页
export function getPurchOrderPage(params) {
  return request({
    url: prePath + '/orders/page',
    method: 'get',
    params,
  })
}
export function getPurchOrderAll(params) {
  return request({
    url: prePath + '/orders/all',
    method: 'get',
    params,
  })
}

export function getPurchOrderCustomizeListPage(data) {
  return request({
    url: prePath + '/orders/customizeList/page',
    method: 'post',
    data,
  })
}

//创建采购单
export function createPurchOrder(data) {
  return request({
    url: prePath + '/orders',
    method: 'post',
    data,
  })
}
//创建采购单 提交
export function createPurchOrderAndSubmit(data) {
  return request({
    url: prePath + '/orders/saveAndSubmit',
    method: 'post',
    data,
  })
}
export function saveAndSubmitFromApplication(data) {
  return request({
    url: prePath + '/orders/saveAndSubmitFromApplication',
    method: 'post',
    data,
  })
}

//从申购单过来的 采购单
export function createPurchOrderFromApplication(data) {
  return request({
    url: prePath + '/orders/insetFromApplication',
    method: 'post',
    data,
  })
}

//更新采购单
export function updatePurchOrder(data) {
  return request({
    url: prePath + '/orders/byPost',
    method: 'post',
    data,
  })
}

//打印采购单
export function printPurch(id) {
  return request({
    url: prePath + `/orders/${id}/print`,
    method: 'get',
  })
}

//导出采购单
export function exportPurch(data) {
  return request({
    url: prePath + `/orders/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

//导出采购单
export function exportPurchOrderDetail(data) {
  return request({
    url: prePath + `/orderDetails/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

export function removePurchOrder(data) {
  return request({
    url: prePath + '/orders',
    method: 'delete',
    data,
  })
}

//根据ID查询采购单
export function purchOrderById(id) {
  return request({
    url: prePath + '/orders/' + id,
    method: 'get',
  })
}
//根据ID查询采购单(拷贝状态)
export function purchOrderCopyById(params) {
  return request({
    url: prePath + '/orders/copy',
    method: 'get',
    params,
  })
}

//获取采购单明细
export function getPurchOrderDetailAll(params) {
  return request({
    url: prePath + '/orderDetails/all',
    method: 'get',
    params,
  })
}

//获取采购单编辑页面明细
export function getPurchOrderEditDetailAll(params) {
  return request({
    url: prePath + '/orderDetails/editData',
    method: 'get',
    params,
  })
}

//提交采购单
export function submitPurchOrder(data) {
  return request({
    url: prePath + '/orders/submit',
    method: 'post',
    data,
  })
}

//终止采购单
export function breakPurchOrder(data) {
  return request({
    url: prePath + '/orders/break',
    method: 'post',
    data,
  })
}

// 多单号查询采购单产品列表
export function getOrdersProduct(params) {
  return request({
    url: prePath + '/orderDetails/simpleAll',
    method: 'get',
    params,
  })
}

//根据申购单id生成采购单，只展示给前端
export function frontPurchOrderByApplicationId(purchApplicationId) {
  return request({
    url: prePath + '/orders/front/application/' + purchApplicationId,
    method: 'get',
  })
}

// 根据申购单id生成采购单明细
export function frontPurchOrderByApplicationDetail(data) {
  return request({
    url: prePath + '/orders/front/application/details',
    method: 'post',
    data,
  })
}
// 根据申购单id生成主单据
export function frontPurchOrderByApplicationOrder(data) {
  return request({
    url: prePath + '/orders/front/application/order',
    method: 'post',
    data,
  })
}
//批量生成采购单
export function patchInsetFromApplication(data) {
  return request({
    url: prePath + '/orders/patchInsetFromApplication',
    method: 'post',
    data,
  })
}

// 采购退货分页查询
export function getPurchReturnPage(data) {
  return request({
    url: prePath + '/purchReturn/customizeList/page',
    method: 'post',
    data,
  })
}
//获取销售退货
export function getSaleReturnOrder(params) {
  return request({
    url: prePath + '/purchReturn/page',
    method: 'get',
    params,
  })
}
//获取销售退货详情
export function getSaleReturnOrderDetailAll(params) {
  return request({
    url: prePath + '/purchReturnDetail/mergeList',
    method: 'get',
    params,
  })
}
//获取销售退货详情
export function excelPurchReturn(data) {
  return request({
    url: prePath + '/purchReturn/excel',
    method: 'post',
    data,
    responseType: 'blob',
  })
}
export function excelPurchReturnDetail(data) {
  return request({
    url: prePath + '/purchReturnDetail/excel',
    method: 'post',
    data,
    responseType: 'blob',
  })
}
//采购退货详情页打印数据
export function getPurchReturnPrint(data) {
  return request({
    url: prePath + '/purchReturn/print',
    method: 'post',
    data,
  })
}
//供应商确认
export function checkSaleReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn/check',
    method: 'post',
    data,
  })
}
//供应商拒收
export function refuseSaleReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn/refuse',
    method: 'post',
    data,
  })
}
//供应商拒绝
export function rejectSaleReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn/reject',
    method: 'post',
    data,
  })
}
//供应商收货
export function receiveSaleReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn/receive',
    method: 'post',
    data,
  })
}
//获取采购退货详情
export function detailPurchReturn(id) {
  return request({
    url: prePath + '/purchReturn/' + id,
    method: 'get',
  })
}
//采购退货明细
export function purchReturnDetailsCustomizeListAll(data) {
  return request({
    url: prePath + '/purchReturnDetail/customizeList/all',
    method: 'post',
    data,
  })
}
export function purchReturnDetailsCustomizeListPage(data) {
  return request({
    url: prePath + '/purchReturnDetail/customizeList/page',
    method: 'post',
    data,
  })
}
//采购退货获取分组
export function getPurchReturnCustomizeGroups(data) {
  return request({
    url: prePath + '/purchReturnDetail/customizeGroups',
    method: 'post',
    data,
  })
}
// 采购退货新增
export function createPurchReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn',
    method: 'post',
    data,
  })
}
// 采购退货新增 保存并提交
export function createPurchReturnOrderAndSave(data) {
  return request({
    url: prePath + '/purchReturn/saveAndSubmit',
    method: 'post',
    data,
  })
}

// 采购退货修改
export function updatePurchReturnOrder(data) {
  return request({
    url: prePath + '/purchReturn',
    method: 'put',
    data,
  })
}

// 查询采购退货详情
export function getPurchReturnOrderDetail(id) {
  return request({
    url: prePath + '/purchReturn/' + id,
    methods: 'get',
  })
}

// 查询采购退货单产品个体码未分页
export function getPurchReturnDetailExtAll(params) {
  return request({
    url: prePath + '/purchReturnDetailExt/all',
    methods: 'get',
    params,
  })
}

// 查询采购退货单产品个体码分页
export function getPurchReturnDetailExtPage(params) {
  return request({
    url: prePath + '/purchReturnDetailExt/page',
    methods: 'get',
    params,
  })
}

// 采购退货出库
export function purchReturnExport(data) {
  return request({
    url: prePath + '/purchReturn/export',
    method: 'post',
    data,
  })
}

// 采购退货提交
export function purchReturnSubmit(data) {
  return request({
    url: prePath + '/purchReturn/submit',
    method: 'post',
    data,
  })
}

// 采购退货撤回
export function purchReturnRetract(data) {
  return request({
    url: prePath + '/purchReturn/revoke',
    method: 'post',
    data,
  })
}
// 采购退货作废
export function purchReturnInvalid(data) {
  return request({
    url: prePath + '/purchReturn/invalid',
    method: 'post',
    data,
  })
}

// 采购退货撤回出库
export function purchReturnBreakUpExport(data) {
  return request({
    url: prePath + '/purchReturn/breakUpExport',
    method: 'post',
    data,
  })
}
//采购退货打印
export function printReturnOrder(id) {
  return request({
    url: prePath + `/purchReturn/${id}/print`,
    method: 'get',
  })
}

// 采购退货删除
export function purchReturnDelete(data) {
  return request({
    url: prePath + '/purchReturn',
    method: 'delete',
    data,
  })
}

//调价单分页
export function getAdjustPriceOrderPage(data) {
  return request({
    url: prePath + '/adjustPriceOrders/customizeList/page',
    method: 'post',
    data,
  })
}

//调价记录查询
export function adjustPriceSelectByProductId(params) {
  return request({
    url: prePath + '/adjustPriceOrderDetails/selectByProductId',
    method: 'get',
    params,
  })
}

//获取调价单
export function getAdjustPriceOrder(id) {
  return request({
    url: prePath + `/adjustPriceOrders/${id}`,
    method: 'get',
  })
}

//创建调价单
export function createAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders',
    method: 'post',
    data,
  })
}
export function createAdjustPriceOrderAndSave(data) {
  return request({
    url: prePath + '/adjustPriceOrders/saveAndSubmit',
    method: 'post',
    data,
  })
}

//更新调价单
export function updateAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders',
    method: 'put',
    data,
  })
}

//调价明细全部
export function getAdjustPriceOrderDetailsAll(data) {
  return request({
    url: prePath + '/adjustPriceOrderDetails/customizeList/all',
    method: 'post',
    data,
  })
}

export function getAdjustPriceOrderDetailsGroup(data) {
  return request({
    url: prePath + '/adjustPriceOrderDetails/customizeGroups',
    method: 'post',
    data,
  })
}

export function getAdjustPriceOrderDetailsPage(data) {
  return request({
    url: prePath + '/adjustPriceOrderDetails/customizeList/page',
    method: 'post',
    data,
  })
}

//调价单-提交
export function submitAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/submit',
    method: 'post',
    data,
  })
}
//调价单-批准
export function approveAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/approved',
    method: 'post',
    data,
  })
}
//调价单-驳回
export function rejectAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/reject',
    method: 'post',
    data,
  })
}
//调价单-拒绝
export function refuseAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/refuse',
    method: 'post',
    data,
  })
}
//调价单-批量撤回
export function recallAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/revoke',
    method: 'post',
    data,
  })
}
//调价单-批量销审
export function salesReviewAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders/cancelCheck',
    method: 'post',
    data,
  })
}
//调价单-删除
export function delAdjustPriceOrder(data) {
  return request({
    url: prePath + '/adjustPriceOrders',
    method: 'delete',
    data,
  })
}

//获取智能订单分页
export function getSmartOrderPage(params) {
  return request({
    url: prePath + '/smartOrders/page',
    method: 'get',
    params,
  })
}

//获取智能订单
export function getSmartOrder(id) {
  return request({
    url: prePath + `/smartOrders/${id}`,
    method: 'get',
  })
}

//创建智能订单
export function createSmartOrder(data) {
  return request({
    url: prePath + `/smartOrders`,
    method: 'post',
    data,
  })
}

//更新智能订单
export function updateSmartOrder(data) {
  return request({
    url: prePath + `/smartOrders`,
    method: 'put',
    data,
  })
}

//删除智能订单
export function deleteSmartOrder(data) {
  return request({
    url: prePath + `/smartOrders`,
    method: 'delete',
    data,
  })
}

//获取智能订单明细
export function getSmartOrderDetailAll(params) {
  return request({
    url: prePath + `/smartOrderDetails/all`,
    method: 'get',
    params,
  })
}

// 采购单撤回
export function puchOrderRevoke(data) {
  return request({
    url: prePath + '/orders/revoke',
    method: 'post',
    data,
  })
}

//采购退货输入入库单号
export function purchReturnUpdateReceive(data) {
  return request({
    url: prePath + '/purchReturn/updateReceive',
    method: 'post',
    data,
  })
}
//申购汇总订单页
export function getApplicationSummaryOrderPage(data) {
  return request({
    url: prePath + '/applicationSummary/customizeList/page',
    method: 'post',
    data,
  })
}
//申购汇总订单页
export function getApplicationSummaryOrderById(id) {
  return request({
    url: prePath + '/applicationSummary/' + id,
    method: 'get',
  })
}
//申购获取一条打印数据
export function getPurchApplicationSummaryPrint(data) {
  return request({
    url: prePath + '/applicationSummary/print',
    method: 'post',
    data,
  })
}
//申购汇总订单提交
export function applicationSummaryOrderSubmit(data) {
  return request({
    url: prePath + '/applicationSummary/submit',
    method: 'post',
    data,
  })
}
//申购汇总订单撤回
export function applicationSummaryOrderRevoke(data) {
  return request({
    url: prePath + '/applicationSummary/revoke',
    method: 'post',
    data,
  })
}
//申购汇总订单驳回
export function applicationSummaryOrderReject(data) {
  return request({
    url: prePath + '/applicationSummary/reject',
    method: 'post',
    data,
  })
}
//申购汇总订单审批
export function applicationSummaryOrderRatifyt(data) {
  return request({
    url: prePath + '/applicationSummary/ratify',
    method: 'post',
    data,
  })
}
//申购汇总订删除
export function applicationSummaryOrderDelete(data) {
  return request({
    url: prePath + '/applicationSummary',
    method: 'delete',
    data,
  })
}
//新增申购汇总订单页
export function createApplicationSummaryMergeInsert(data) {
  return request({
    url: prePath + '/applicationSummary/mergeInsert',
    method: 'post',
    data,
  })
}
//新增申购汇总订单页  保存并提交
export function createApplicationSummarySaveAndSubmit(data) {
  return request({
    url: prePath + '/applicationSummary/saveAndSubmit',
    method: 'post',
    data,
  })
}
//申购汇总明细
export function applicationSummaryDetailCustomizeListPage(data) {
  return request({
    url: prePath + '/applicationSummaryDetail/customizeList/page',
    method: 'post',
    data,
  })
}
//申购汇总明细
export function applicationSummaryDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/applicationSummaryDetail/customizeList/all',
    method: 'post',
    data,
  })
}
//申购汇总分组查询
export function applicationSummaryDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/applicationSummaryDetail/customizeGroups',
    method: 'post',
    data,
  })
}
//更新合并申购单生成汇总单
export function applicationSummaryMergeUpdate(data) {
  return request({
    url: prePath + '/applicationSummary/mergeUpdate',
    method: 'post',
    data,
  })
}
//申购汇总单删除申购单接口
export function applicationSummaryDeletePurchOrder(data) {
  return request({
    url: prePath + '/applicationSummary/deletePurchOrder',
    method: 'post',
    data,
  })
}

//申购汇总单新增申购单接口
export function applicationSummaryAddPurchOrder(data) {
  return request({
    url: prePath + '/applicationSummary/addPurchOrder',
    method: 'post',
    data,
  })
}
//申购汇总单的申购单驳回
export function applicationSummaryBatchReject(data) {
  return request({
    url: prePath + '/applicationSummary/batchReject',
    method: 'post',
    data,
  })
}
//申购汇总单终止
export function applicationSummaryStop(data) {
  return request({
    url: prePath + '/applicationSummary/stop',
    method: 'post',
    data,
  })
}

export function downloadFileAdjustPriceOrders(data) {
  return request({
    url: prePath + '/adjustPriceOrders/customizeList/download/file',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

//取消拣货
export function purchCancelDownShelf(data) {
  return request({
    url: prePath + '/purchReturn/cancelDownShelf',
    method: 'post',
    data,
  })
}

//带量产品管理
export function purchBandQuantityCustomizeListPage(data) {
  return request({
    url: prePath + '/bandQuantity/customizeList/page',
    method: 'post',
    data,
  })
}
//带量产品管理 新增保存
export function purchBandQuantityAdd(data) {
  return request({
    url: prePath + '/bandQuantity/batchInsert',
    method: 'post',
    data,
  })
}
//带量产品管理 修改
export function purchBandQuantityUpdate(data) {
  return request({
    url: prePath + '/bandQuantity',
    method: 'put',
    data,
  })
}
// 带量产品管理导出
export function exportBandQuantity(data) {
  return request({
    url: prePath + `/bandQuantity/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
// 带量产品管理删除
export function deleteBandQuantity(data) {
  return request({
    url: prePath + '/bandQuantity',
    method: 'delete',
    data,
  })
}

//采购设置
export function agreeQuantityProductCustomizeListPage(data) {
  return request({
    url: prePath + '/agreeQuantityProduct/customizeList/page',
    method: 'post',
    data,
  })
}
//采购设置 新增保存
export function agreeQuantityProductAdd(data) {
  return request({
    url: prePath + '/agreeQuantityProduct/batchInsert',
    method: 'post',
    data,
  })
}
//采购设置 修改
export function agreeQuantityProductUpdate(data) {
  return request({
    url: prePath + '/agreeQuantityProduct',
    method: 'put',
    data,
  })
}
// 采购设置导出
export function exportAgreeQuantity(data) {
  return request({
    url: prePath + `/agreeQuantityProduct/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
// 采购设置删除
export function deleteAgreeQuantity(data) {
  return request({
    url: prePath + '/agreeQuantityProduct',
    method: 'delete',
    data,
  })
}

export function createPurchOrderFlowSaveAndSubmit(data) {
  return request({
    url: prePath + '/orders/flowSaveAndSubmit',
    method: 'post',
    data: {
      orderData: data,
      processDefinitionKey: 'purchOrderApply',
      flowTaskCommentDto: { approvalType: 'submit' },
    },
  })
}

//采购计划
// 采购计划-新增
export function createPurchPlan(data) {
  return request({
    url: prePath + '/plan',
    method: 'post',
    data,
  })
}
// 采购计划-新增-保存并提交
export function saveAndSubmitPurchPlan(data) {
  return request({
    url: prePath + '/plan/saveAndSubmit',
    method: 'post',
    data,
  })
}
// 采购计划-修改
export function updatePurchPlan(data) {
  return request({
    url: prePath + '/plan',
    method: 'put',
    data,
  })
}
// 采购计划-获取1条
export function getPurchPlanById(id) {
  return request({
    url: prePath + '/plan/' + id,
    method: 'get',
  })
}
// 采购计划-删除
export function detetePurchPlan(data) {
  return request({
    url: prePath + '/plan',
    method: 'delete',
    data,
  })
}
// 采购计划-提交
export function submitPurchPlan(data) {
  return request({
    url: prePath + '/plan/submit',
    method: 'post',
    data,
  })
}
//采购计划-导出
export function exportPurchPlan(data) {
  return request({
    url: prePath + `/plan/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}
//采购计划-查询
export function getPurchPlanCustomizeListPage(data) {
  return request({
    url: prePath + `/plan/customizeList/page`,
    method: 'post',
    data,
  })
}
//采购计划-明细
export function getPurchProductDetail(params) {
  return request({
    url: `/purchPlan/productDetail/selectProductDetail`,
    method: 'get',
    params,
  })
}
/**
 * @param ids {[]}
 * @param method {string} break 终止采购单 execute 执行 revoke 撤销 submit 提交
 */
export function methodPurchPlan(data, method) {
  return request({
    url: prePath + '/plan/' + method,
    method: 'post',
    data,
  })
}
//申购单保存校验
export function applicationsValidatePlanRemind(data) {
  return request({
    url: prePath + '/applications/validatePlanRemind',
    method: 'post',
    data,
  })
}
//申购单提交校验
export function applicationsSubmitValidatePlanRemind(data) {
  return request({
    url: prePath + '/applications/submitValidatePlanRemind',
    method: 'post',
    data,
  })
}
//采购单保存校验
export function ordersValidatePlanRemind(data) {
  return request({
    url: prePath + '/orders/validatePlanRemind',
    method: 'post',
    data,
  })
}
//采购单提交校验
export function ordersSubmitValidatePlanRemind(data) {
  return request({
    url: prePath + '/orders/submitValidatePlanRemind',
    method: 'post',
    data,
  })
}
